
class Cleaner {
    private String s = "Cleaner";

    public void append(String s) {
        this.s += s;
    }

    public void dilute() {
        append(" dilute()");
    }

    public void apply() {
        append(" apply()");
    }

    public void scrub() {
        append(" scrub()");
    }

    @Override
    public String toString() {
        return "Cleaner{" +
                "s='" + s + '\'' +
                '}';
    }

    public static void main(String[] args) {
        Cleaner cleaner = new Cleaner();
        cleaner.dilute();
        cleaner.apply();
        cleaner.scrub();
        System.out.println(cleaner);
    }
}

public class ExtendDemo extends Cleaner {
    @Override
    public void scrub() {
        super.scrub();
        append(" ExtendDemo.scrub()");
    }

    public void foam() {
        append(" foam()");
    }

    public static void main(String[] args) {
        ExtendDemo extendDemo = new ExtendDemo();
        extendDemo.dilute();
        extendDemo.apply();
        extendDemo.scrub();
        extendDemo.foam();
        System.out.println(extendDemo);
        System.out.println("Testing base class:");
        Cleaner.main(args);
    }
}
/*
Cleaner{s='Cleaner dilute() apply() ExtendDemo.scrub() foam()'}
Testing base class:
Cleaner{s='Cleaner dilute() apply() scrub()'}
 */
